The R console looks like this:
Make sure that you set up a folder for this class.
You can knit the file. The first time you do this you will need to make sure you have the knitr package installed. You have the option to knit into .html, .pdf, and .doc. In general, in this course we will be knitting into .html.
To make something “code-looking” we use the grave accent ` found in the upper left of your keyboard.
To create a header, place a hash tag at the start of the line. For example, # Header 1 or create a level 2 header using ## Header Level 2.
To make text italics put asterisk around the text *like this*. To make text bold, put two asterisks around the text **like this**.
To make a list, just start creating your list using a - or * for each bullet, like this:
- list item 1
- list item 2
It is important that there is a blank line before the first bullet.
Add a link:
[Alt text that will display](www.google.com)
Add an image:

Alt text
The vast majority of markdown syntax are available in the RStudio RMarkdown Cheatsheet, Section 3.
Create an R chunk:
2+2
## [1] 4
OR
x<-4
echo=T or echo=F– determines whether or not to echo the source code in the output file. This can be useful if you are creating a document for someone to read that doesn’t need to see or doesn’t want to see you code, just the output. In general in this course for assignments I would like your code to be echoed. The default is echo=F.
results=T or results=F – determines whether or not the results will be displayed. This can be useful if you want to show code, but don’t care what the output is. The default is eval=T.
eval=T or eval=F – determines whether or not to evaluate the code. This can be useful if you have a whole chunk of code you don’t want run, but you also don’t want to. The default is eval=T.
There are many, many more options including fig.width, fig.height, cache, etc. The vast majority of options are available in the RStudio RMarkdown Cheatsheet, Section 5.
You have the option to set the options individually on each chunk and/or set the global options by using the code knitr::opts_chunk$set(your options here)) in the first code chunk.
Rather than using a code chunk (which is centered in the middle of the page), you also have to options to use inline code. You can place the following within any sentence or paragraph.
`r codehere`
For example,
This is the number `r x`.
becomes… This is the number 4.
Packages can contain lots of things including: data sets, functions, etc.
You can install packages using the packages tab or you can use the code install.packages('packageyouwant') in the console.
In each new R session where you want to use the package you will have to load it by typing library('packageyouwant') in the console (or in the RMarkdown document - more later).
To get help with a package (or a function in a package) you can type ?packagename into the console.
Assigning Variables:
Calculations:
Vectors:
Referencing Elements of a Vector:
Adding to Vectors:
From a file on your computer:
From the web:
For now, we will mostly be working with .csv and .xls files. Later in the course, we may discuss other types of files.
Assessing Size:
Names:
Referencing Columns:
Calculations:
Conditional Subsetting:
# before a line of comment)When naming variables, observations, data frames, or files, make them:
Other naming considerations:
filter or mean)surface_temp= surface temperature measurement on Mars in degrees Celsius)Some suggestions for best practices:
purple vs. Purple vs. purple_)NA, NaN, -9999, -); don’t leave cells blankby @alisonhorst